<template>
	<view class="root">
		<view id="header">
			<view class='headervw'>
				<view class='headertx'>
					{{detailData.title}}
				</view>
			</view>
			<view class="line"></view>
		</view>
		<view id="body" class="body">
			<view class="content">
				<rich-text :nodes="detailData.htmlNodes" style="font-size: 30upx;"></rich-text>
			</view>
		</view>
	</view>
</template>

<script>
	import uParse from '@/components/u-parse/u-parse.vue';
	import htmlParser from '@/config/html-parser'
	export default {
		data() {
			return {
				Uuid:'',
				detailData: {
					title: '',
					htmlNodes: ''
				},
			}
		},
		components: {
			uParse
		},
		onLoad(options) {
			if (options) {
				this.dataUuid = options.dataUuid
				console.log(this.dataUuid)
				// this.flag = options.flag
				this.getArticalDetails(this.dataUuid)
			}
		},
		methods: {
			getArticalDetails(dataUuid){
				let params = {
				 	"pressReleaseUuid":dataUuid
				}
				this.$api.request.getArticalDetails(params, (res) => {
					console.log(res.body.data)
					if (res.body.status.statusCode == "0") {
						this.detailData = res.body.data.pressReleaseEntity
					}
					var content = this.detailData.content;
					// content = content.replace(/<!DOCTYPE html>/g, "").replace(/<html>/g, "").replace(
					// 	/<\/html>/g, "").replace(/<head>/g, "").replace(/<\/head>/g, "").replace(/<body>/g,
					// 	"").replace(/<\/body>/g, "")
					// var article = content.replace(/(\<img|\<p)/gi, function($0, $1) {
					// 	return {
					// 		"<img": '<img style="width:100%;height:auto;display:block;" ',
					// 		"<p": '<p style="text-indent: 0;" ',
					// 		"<article": "<div",
					// 		"</article": "</div",
					// 		"<header": "<div",
					// 		"</header": "</div"
					// 	} [$1];
					// });
					// console.log(article)
					this.detailData.htmlNodes = this.$api.htmlParser.parseHtml(content);
				})
			},
		}
	}
</script>

<style>
	
	page{
		background-color: #FBFBFB;
	}
	
	.root {
		width: 100%;
		height: 100%;
		padding: 40upx;
		padding-top: 10upx;
	}

	.headervw {
		width: 100%;
		/* height: 60upx; */
		text-align: center;
	}

	.headertx {
		font-size: 36upx;
		font-weight: bold;
		/* line-height: 60upx; */
	}

	.line {
		width: 100%;
		height: .5upx;
		background-color: #a1a1a1;
		margin-top: 10upx;
	}

	.content {
		width: auto;
		margin-top: 20upx;
	}

	.content_title {
		font-size: 32upx;
		font-weight: bold;
	}

	.content_desc {
		font-size: 28upx;
		margin-top: 20upx;

		width: 100%;
		font-weight: normal;
	}
</style>
